package escritorio.conn;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import escritorio.javaBeans.Processo;

public class ProcessoDao {
	private Connection conn;

	public ProcessoDao() {
		super();
		this.conn = new ConnectionFactory().getConnection();
	}

	@SuppressWarnings("deprecation")
	public void insereProcesso(Processo processo) {
		String sql = "insert into processo "
				+ "(nroProcesso,descricao,dataAbertura)"
				+ " Values (?,?,?)";
		try {
			PreparedStatement stmt = conn.prepareStatement(sql);
			stmt.setString(1, processo.getNroProcesso());
			stmt.setString(2, processo.getDescricao());
			stmt.setDate(3, new Date(processo.getDataAbertura().getDate()));
			//stmt.setDate(4, new Calendar(processo.getDataAbertura().getTime()));
			//stmt.setDate(4, new Date(processo.getDataConclusao().getDate()));

			stmt.execute();
			stmt.close();
		} catch (SQLException e) {
			throw new ConnErro(null, e);
		}
	}

}
